﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dukou.Example.DTO.Domain;
using Dukou.Example.DTO.DTO;
using Dukou.DTO;
using Dukou.Example.DTO.Parsers;

namespace Dukou.Example.DTO.Test
{
    public class TestCustomerParser
    {
        public static void Test()
        {
            User creator = new User()
            {
                Id = 1,
                UserName = "matt fang",
                Password = "123456",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
            };

            creator.Creator = creator;
            creator.Updator = creator;

            Customer customer = new Customer()
            {
                Id = 1,
                CustomerName = "宝钢股份有限公司",
                MemberCards = new List<MemberCard>(),
                UpdateTime = DateTime.Now,
                Updator = creator,
                Creator = creator,
                CreateTime = DateTime.Now.AddDays(-1),
            };

            customer.MemberCards.Add(new MemberCard() 
            {
                Id = 1,
                Customer = customer,
                CardNumber = "234098"
            });
            customer.MemberCards.Add(new MemberCard()
            {
                Id = 2,
                Customer = customer,
                CardNumber = "234099"
            });

            CustomerDTO dto = ObjectParser.Parse<CustomerDTO, Customer, CustomerParser>(customer, new Dictionary<string, ObjectCache>(), 3);

            customer = ObjectParser.Parse<CustomerDTO, Customer, CustomerParser>(dto, new Dictionary<string, ObjectCache>(), 0);

            
        }
    }
}
